<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<fieldset class="form-container " style="width:83%;margin-left:5%;"> 
    <form:form id="form_782213"    method="post" action="/contrat/search.do" modelAttribute="contrat" autocomplete="on">
        <legend class="form-title"><h2>Rechercher un contrat</h2></legend>
        <h3 style="margin-bottom: 5%;margin-left: 1%">Veuillez renseigner les champs ci-dessous :</h3>
        <form:errors path="*" cssClass="errorblock" element="div"></form:errors>
        <form:hidden path="id"/>
        <fieldset class="form-container " style="float: left;position: relative;" >
            <legend class="form-title">Par adh&eacute;rent</legend>
            <div  style="float: left;position: relative;">
                <div class="form-title">Nom Pr&eacute;nom </div>
                <form:input class="form-field" type="text" path="adherent.nomPrenom" tabindex="1"/>


                <div class="form-title">Num&eacute;ro URSSAF </div>
                <form:input class="form-field" type="text" path="adherent.numUrssaf" tabindex="9"/>
            </div>
            <div style="float: left;position: relative;">
                <div class="form-title" style="margin-top:55px;">&nbsp;</div>
                <div class="form-title">Num&eacute;ro Siret</div>
                <form:input class="form-field" type="text" path="adherent.numSiret" tabindex="10"/>
            </div>
        </fieldset>
        <fieldset class="form-container " style="float: left;position: relative;" >
            <legend class="form-title">Par employ&eacute;</legend>
            <div style="float: left;position: relative;">
                <div class="form-title">Nom  </div>
                <form:input class="form-field" type="text" path="employe.nom" tabindex="1"/>


                <div class="form-title">Num&eacute;ro S&eacute;curit&eacute; social</div>
                <form:input class="form-field" type="text" path="employe.numSecu" tabindex="10"/>
            </div>
            <div style="float: left;position: relative;">

                <div class="form-title">Pr&eacute;nom  </div>
                <form:input class="form-field" type="text" path="employe.prenom" tabindex="1"/>
            </div>
        </fieldset>
        <div class="submit-container" style=" clear: left;margin-top: 10%;">
            <form:button class="submit-button" type="submit" >Rechercher</form:button>
                <a href="/contrat/index.do" class="submit-button">Annuler</a>
            </div>
    </form:form>
</fieldset>
<c:choose>
    <c:when test="${listAdherent==null && listEmploye==null}"> </c:when>
    <c:when test="${listAdherent.size()==0 && listEmploye.size()==0}"> <div class="info message" style="margin-top: 15%;">Pas de r&eacute;sultat</div></c:when>
    <c:otherwise>
        <div  style="margin-top: 15%;">
            <table id="myTable"  class="tablesorter">
                <thead>
                    <tr>
                        <th>Nom Pr&eacute;nom</th>
                        <th>Adresse</th>
                        <th>T&eacutel&eacute;phone</th>
                        <th>Mobile</th>
                        <th colspan="2">Contrat</th>

                    </tr>
                </thead>
                <!--<tfoot><tr><td colspan="4"><div id="paging"><ul><li><a href="#"><span>Previous</span></a></li><li><a href="#" class="active"><span>1</span></a></li><li><a href="#"><span>2</span></a></li><li><a href="#"><span>3</span></a></li><li><a href="#"><span>4</span></a></li><li><a href="#"><span>5</span></a></li><li><a href="#"><span>Next</span></a></li></ul></div></tr></tfoot>-->



                <tbody>

                    <c:forEach var="adherent" items="${listAdherent}" varStatus="vs">
                        <tr <c:if test="${vs.count %2==0}">class="alt"</c:if>>
                            <td><a href="/adherent/show.do?id=${adherent.id}">${adherent.nomPrenom}</a></td>

                            <td>${adherent.adresse}<br/>
                                ${adherent.complementAdresse}<br/>
                                ${adherent.codePostal} - ${adherent.ville}
                            </td>
                            <td>${adherent.telephone}</td>
                            <td>${adherent.mobile}</td>
                            <td>
                                <c:forEach var="contrat" items="${adherent.contrats}" varStatus="vs">
                                    <a href="/contrat/show.do?id=${contrat.id}">${contrat.id}  ${contrat.employe.nom} - ${contrat.employe.prenom}</a><br/><br/>

                                </c:forEach>


                            </td>
                            <td> 
                                <c:forEach var="contrat" items="${adherent.contrats}" varStatus="vs">
                                    <a href="/bulletin/add.do?idContrat=${contrat.id}">Saisir un bulletin de paie</a><br/>
                                    <a href="#">Saisir une facture</a><br/>
                                </c:forEach>
                            </td>
                        </tr>
                    </c:forEach>
                    <c:forEach var="employe" items="${listEmploye}" varStatus="vs">
                        <tr <c:if test="${vs.count %2==0}">class="alt"</c:if>>
                            <td><a href="/employe/show.do?id=${employe.id}">${employe.nom}-${employe.prenom}</a></td>

                            <td>${employe.adresse}<br/>
                                ${employe.complementAdresse}<br/>
                                ${employe.codePostal} - ${employe.ville}
                            </td>
                            <td>${employe.telephone}</td>
                            <td>${employe.mobile}</td>
                            <td>
                                <c:forEach var="contrat" items="${employe.contrats}" varStatus="vs">
                                    <a href="/contrat/show.do?id=${contrat.id}">${contrat.adherent.nomPrenom}</a><br/><br/>

                                </c:forEach>


                            </td>
                            <td> 
                                <c:forEach var="contrat" items="${employe.contrats}" varStatus="vs">
                                    <a href="/bulletin/add.do?idContrat=${contrat.id}">Saisir un bulletin de paie</a><br/>
                                    <a href="#">Saisir une facture</a><br/>
                                </c:forEach>
                            </td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
            <div id="pager" class="pager">
                <form>
                    <img src="/img/first.png" class="first">
                    <img src="/img/prev.png" class="prev">
                    <input type="text" class="pagedisplay">
                    <img src="/img/next.png" class="next">
                    <img src="/img/last.png" class="last">
                    <select class="pagesize">
                        <option selected="selected" value="10">10</option>
                        <option value="20">20</option>
                        <option value="30">30</option>
                        <option value="40">40</option>
                    </select>
                </form>
            </div>

        </div>
    </c:otherwise>
</c:choose>


<script>
    $(function() {


        $("table").tablesorter({widgets: ['zebra']}).tablesorterPager({container: $("#pager")});

    });
</script>